package cn.com.jslh.boarpro.main.presenter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;

import net.idik.lib.slimadapter.SlimAdapterEx;

import java.util.ArrayList;

import cn.com.jslh.boarpro.base.mvp.BaseListPresenter;
import cn.com.jslh.boarpro.base.mvp.BaseListView;
import cn.com.jslh.boarpro.main.model.AddDeliveryRecordModelImpl;
import cn.com.jslh.boarpro.tables.WeanTable;
import cn.com.jslh.boarpro.util.database.DataBaseUtil;

/**
 * 分娩记录
 * 作者：周洲 on 2017/7/28 10:40
 * <p>
 * 邮箱：double0zhou@126.com
 */

public class AddDeliveryRecordPresenterImpl extends BaseListPresenter {

    private SlimAdapterEx infoAdapter;

    public AddDeliveryRecordPresenterImpl(Context context, BaseListView baseListView) {
        super(context, baseListView, new AddDeliveryRecordModelImpl(context));
    }

    @Override
    public void upDatas(String... param) {
        //提交数据
    }

    @Override
    public void setUI(RecyclerView recyclerView, String... params) {
    }

    /**
     * 新增记录
     * @param params
     */
    public boolean subBreedingRecordItemInfo(String... params){
        ArrayList<Object> datas = DataBaseUtil.GetData(context, WeanTable.class, " where muZhuID = '" + params[0] + "'");
        if(datas.size()>0){
            Toast.makeText(context, "不能重复提交母猪数据", Toast.LENGTH_SHORT).show();
            return false;
        }else {
            ((AddDeliveryRecordModelImpl) baseListModel).save2Db(params);
            baseListView.onItemClicked("记录新增成功");
            return true;
        }
    }
}
